<?php
/*
 +----------------------------------------------------------------------
 | TEMMOKUMVC [ NO BEST, ONLY BETTER ]
 +----------------------------------------------------------------------
 | Copyright (c) 2018~2019 https://www.temmoku.cn All rights reserved.
 +----------------------------------------------------------------------
 | Author: 张宗强 Email:webmaster@temmoku.cn QQ:158726877 516669373 TEL:17895221001 微信:temmokumvc
 +---------------------------------------------------------------------- 
*/
namespace plugin\login\admin\controller;
use \temmoku\controller;
use \temmoku\db;
use plugin\login\admin\model\index AS model;
use plugin\login\public_class\cache;
class index extends controller{
	
	public function reg(){
		if('post'===$_POST['step']){
			foreach($_POST['web'] AS $key=>$name){
				$one=db::select('*')->from(P_jab."set")->where("u_key LIKE '$key' ")->row();
				if($one){
					db::update(P_jab."set")->cols(array('u_value'))->where("u_key LIKE '$key'")->bindValue('u_value', "$name")->query();
				}else{
					db::insert(P_jab."set")->cols(array('u_key'=>"$key",'u_value'=>"$name"))->query();
				}
			}
			cache::setting_cache();
			$this->success('修改成功');
		}
		
		$plugin_route_file=APP_PATH.'plugin_route.php';
		is_file($plugin_route_file) && extract(include $plugin_route_file);
		if(!in_array('sms',$Plugin_Route)){
			$is_sms='0';
		}else{
			$is_sms='1';
		}
		$data=(new model)->get_setting_data();
		$this->assign('data', $data);
		$this->assign('is_sms', $is_sms);
		$this->display(tpl('index/reg'));
	}
	
	public function login(){
		if('post'===$_POST['step']){
			foreach($_POST['web'] AS $key=>$name){
				$one=db::select('*')->from(P_jab."set")->where("u_key LIKE '$key' ")->row();
				if($one){
					db::update(P_jab."set")->cols(array('u_value'))->where("u_key LIKE '$key'")->bindValue('u_value', "$name")->query();
				}else{
					db::insert(P_jab."set")->cols(array('u_key'=>"$key",'u_value'=>"$name"))->query();
				}
			}
			cache::setting_cache();
			$this->success('修改成功');
		}
		$data=(new model)->get_setting_data();
		$this->assign('data', $data);
		$this->display(tpl('index/login'));
	}
	
	public function forgot(){
		if('post'===$_POST['step']){
			foreach($_POST['web'] AS $key=>$name){
				$one=db::select('*')->from(P_jab."set")->where("u_key LIKE '$key' ")->row();
				if($one){
					db::update(P_jab."set")->cols(array('u_value'))->where("u_key LIKE '$key'")->bindValue('u_value', "$name")->query();
				}else{
					db::insert(P_jab."set")->cols(array('u_key'=>"$key",'u_value'=>"$name"))->query();
				}
			}
			cache::setting_cache();
			$this->success('修改成功');
		}
		$data=(new model)->get_setting_data();
		$this->assign('data', $data);
		$this->display(tpl('index/forgot'));
	}
}
?>
